package com.ag.zrt.service.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.ag.bean.TbUser;
import com.ag.zrt.dao.TbUpdateCTIDAO;
import com.ag.zrt.service.IUpdateCTIService;


public class UpdateCTIServiceImpl implements IUpdateCTIService {
	@Resource(name = "ZRTTbUpdateCTIDAO")
	private TbUpdateCTIDAO updateCTIDAO;

	public void setUpdateCTIDAO(TbUpdateCTIDAO updateCTIDAO) {
		this.updateCTIDAO = updateCTIDAO;
	}
	
	public void updateAgent(String UId, String UCtiId, String UCtiNumber,
			String UCtiQueue, String UCtiPsw){
		System.out.println("*******************更新完毕1*******************************");
		//Session s = null;
		try {
			System.out.println("*******************更新完毕1*******************************");
			TbUser user = updateCTIDAO.findById(UId);
			System.out.println("*******************更新完毕2*******************************");
			System.out.println("service:  uId: " + UId + "  uCtiId:" + UCtiId
					+ " uCtiNumber:" + UCtiNumber + " uCtiQueue:" + UCtiQueue
					+ " uCtiPsw:" + UCtiPsw);
			user.setUCtiId(UCtiId);
			user.setUCtiNumber(UCtiNumber);
			user.setUCtiQueue(UCtiQueue);
			user.setUCtiPsw(UCtiPsw);
			updateCTIDAO.attachDirty(user);
		//	s = userDAO.getSessionFactory().openSession();
		//	Transaction t = (Transaction) s.beginTransaction();
			//s.update(user);
			System.out.println("*******************更新完毕3*******************************");
		//	t.commit();
		//	s.close();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} 
//		finally {
//			if (s != null)
//				s.close();
//		}
	}
}
